﻿using System;
using woaC2.LogicLib.GlobalShare;
using woaC2.SocketLib;
using woaC2.Common;

namespace woaC2.SocketApp
{
    public class CommandCtrl
    {
        internal static void StartCommand()
        {
            Log.WriteOnScreen1("Wait...");

            if (!SocketServer.Instance.InitSocket(AssetsGS.instance.SocketConfig_Port))
            {
                Log.WriteOnScreen1("Server Started.");
            }
            else
            {
                Log.WriteOnScreen1("Start Server at Port {0} ...", AssetsGS.instance.SocketConfig_Port);
            }
        }

        internal static void StopCommand()
        {
            Log.WriteOnScreen1("Wait...");
            SocketServer.Instance.StopSocket();
            Log.WriteOnScreen1("Server Stoped.");          
        }

        internal static void MaxCCUCommand(params string[] par)
        {
            var maxCCU = Convert.ToUInt16(par[0]);
            AssetsGS.instance.SocketConfig_MaxxCCU = maxCCU;
            SocketServer.Instance.SetMaxCCU(maxCCU);
            Log.WriteOnScreen1("Set maxCCU = {0} for Server Success.",maxCCU);
        }



        internal static void CCUCommand()
        {
            Log.WriteOnScreen1("CCU: {0}", SocketServer.Instance.CCU);       
        }

        internal static string ByteToString(byte[] buff)
        {
            string sbinary = "";

            for (int i = 0; i < buff.Length; i++)
            {
                sbinary += buff[i].ToString("X2"); // hex format
            }
            return (sbinary);
        }

        internal static void PORTCommand()
        {
        }

    }
}
